import { find } from "cc";
import AudioMgr from "./AudioMgr";
import Instance from "../Utils/Instance";

export default class AudioManager {
    private audioMgr: AudioMgr;
    public readonly btnSound: string = `v4.mp3`;
    public static get ins(): AudioManager {
        return Instance.get(AudioManager);
    }
    constructor() {
        this.audioMgr = find(`AudioSource`).getComponent(`AudioMgr`) as AudioMgr;
    }
    /**
     * 播放音效
     * @param val 文件名 
     */
    public playShot(val: string): void {
        this.audioMgr.playEffect(val);
    }
    /**
     * 设置是否播放背景音乐
     * @param val 
     */
    public isplayMusic(val: boolean) {
        this.audioMgr.setBgOn(val);
    }
    public setMusicClip(val: string) {
        this.audioMgr.setMusicClip(val);
    }
    public stopBg() {
        this.audioMgr.stopBg();
    }
    public pauseBg() {
        this.audioMgr.pauseBg();
    }
    /**
     * 设置是否播放音效
     * @param val 
     */
    public isplayShot(val: boolean) {
        this.audioMgr.setEffectOn(val);
    }
    /**
     * 是否播放背景音乐
     */
    public get isPlayBg(): boolean {
        return this.audioMgr.bgIsOn;
    }
    /**
     * 是否播放音效
     */
    public get isPlayShot(): boolean {
        return this.audioMgr.effectIsOn;
    }

}